home *** CD-ROM | disk | FTP | other *** search
- //basic do-little shader
- //1 directional light applied
-
- //Luke Lenhart
- //(C)2004-2005 Digipen Institute of Technology
-
- //combined world,view,projection transform
- float4x4 matWorldViewProj;
-
- //directional light (assumed to be the sun)
- float4 lgtDirection;
- float4 lgtDiffuse;
- float4 lgtAmbient;
-
- //shader input
- struct VS_INPUT
- {
- float4 Pos : POSITION;
- float4 Normal : NORMAL;
- float2 Tex0 : TEXCOORD0;
- };
-
- //shader output
- struct VS_OUTPUT
- {
- float4 Pos : POSITION;
- float4 Color : COLOR;
- float2 Tex0 : TEXCOORD0;
- };
-
- //shader code
- VS_OUTPUT VShader(VS_INPUT In)
- {
- VS_OUTPUT Out;
-
- //calc directional light color
- Out.Color=dot(In.Normal,lgtDirection)*lgtDiffuse + lgtAmbient;
-
- //calc transformed position and copy texture coord
- Out.Pos=mul(matWorldViewProj,In.Pos);
- Out.Tex0=In.Tex0;
-
- //spit out the results
- return Out;
- }
-